package com.zhumo.sz.service.impl;


import com.zhumo.sz.common.CommonInsert;
import com.zhumo.sz.entity.user.UserInfo;
import com.zhumo.sz.mapper.UserMapper;
import com.zhumo.sz.mock.UserMockRecord;
import com.zhumo.sz.mock.UserMocker;
import com.zhumo.sz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 增加用户
     * @return
     */
    @Override
    public CommonInsert<UserInfo> addUser(int num,int flush) {
        if (flush == 1){
            userMapper.clearUser();
        }
        UserMockRecord<UserInfo> userMockRecord = UserMocker.mock(num, flush == 1, "sz_trffic", "user_info");
        List<UserInfo> userInfoList = userMockRecord.getUserInfoList();
        int result = userMapper.addUser(userInfoList);
        return new CommonInsert<UserInfo>(userInfoList.size(),result);
    }
}
